import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/home',
    name: 'home',
    redirect:"/home/handpick",
    component: HomeView,
    children:[
      {
        path:"handpick",
        name:"handpick",
        component:()=>import("@/views/home/HandpickView.vue")
      },
      {
        path:"free",
        name:"free",
        component:()=>import("@/views/home/FreeView.vue")
      },
      {
        path:"man",
        name:"man",
        component:()=>import("@/views/home/ManView.vue")
      },
      {
        path:"girl",
        name:"girl",
        component:()=>import("@/views/home/GirlView.vue")
      },
      {
        path:"publish",
        name:"publish",
        component:()=>import("@/views/home/PublishView.vue")
      },
      {
        path:"listen",
        name:"listen",
        component:()=>import("@/views/home/ListenView.vue")
      },
    ]
  },
  {
    path: '/bookshelf',
    name: 'bookshelf',
    component: ()=>import("@/views/BookshelfView.vue")
  },
  {
    path: '/class',
    name: 'class',
    component: ()=>import("@/views/ClassView.vue")
  },
  {
    path: '/mine',
    name: 'mine',
    component: ()=>import("@/views/MineView.vue")
  },
  //书籍详情
  {
    path: '/detail/:bookid/:title',
    name: 'detail',
    component: ()=>import("@/views/detail/DetailView.vue")
  },
  //阅读模块
  {
    path: '/read/:bookid',
    name: 'read',
    component: ()=>import("@/views/detail/ReadView.vue")
  },
  //排行榜模块
  {
    path: '/ranking/:url',
    name: 'ranking',
    component: ()=>import("@/views/RankingView.vue")
  },
  //搜索模块
  {
    path: '/search',
    name: 'search',
    component: ()=>import("@/views/search/SearchView.vue")
  },
  {
    path:"/",
    name:"start",
    redirect:"/home"
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
